package com.yms.spring.bean;

import org.springframework.beans.factory.FactoryBean;
import java.util.Objects;

/**
 * @version : 1.0
 * @author: yangmingsong
 * @date: 2022/6/26-06-26-12:47
 * @description: spring5Test
 */
public class User implements FactoryBean {


    private String username;

    private String password;

    private Student student;


    public void run(){
        System.out.println("调用到此方法了");
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public Object getObject() throws Exception {
        return new Student();
    }

    @Override
    public Class<?> getObjectType() {
        return Student.class;
    }

    public Student getStudent() throws CloneNotSupportedException {
        return student==null?null:student.clone();
    }

    public void setStudent(Student student) {
        this.student = student;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        User user = (User) o;
        return Objects.equals(username, user.username) &&
                Objects.equals(password, user.password) &&
                Objects.equals(student, user.student);
    }

    @Override
    public int hashCode() {
        return Objects.hash(username, password, student);
    }
}
